package com.custom.adz.custom;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by Administrator on 2017/4/20.
 */

public class LampView extends View{
    Paint paint;
    private float mViewWidth;
    private float mViewHeight;
    private float mStrokeWidth;
    private RectF mRectF;
    private float mCircleRadiusWatcher;
    private float mCenterX;
    private float mCenterY;
    public LampView(Context context, AttributeSet attrs) {
        super(context, attrs);


    }
    private void initialize(Canvas canvas){
        float density = getResources().getDisplayMetrics().density;
        mStrokeWidth = 10 * density;
        mViewWidth = canvas.getWidth();
        mViewHeight = canvas.getHeight();
        mCircleRadiusWatcher = mViewWidth / 3;
        mCenterX = mViewWidth / 2;
        mCenterY = mViewHeight / 2;
        mRectF = new RectF(mCenterX - mCircleRadiusWatcher, mCenterY - mCircleRadiusWatcher
                , mCenterX + mCircleRadiusWatcher, mCenterY + mCircleRadiusWatcher);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        initialize(canvas);
        paint=new Paint();
        paint.setAntiAlias(true);
        paint.setColor(Color.GRAY);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(mStrokeWidth);
        paint.setStrokeJoin(Paint.Join.ROUND);
        paint.setStrokeCap(Paint.Cap.ROUND);
        canvas.drawArc(mRectF, 10, 240, false, paint);
    }
}
